window._requiresReload=true;"use strict";(self.webpackChunk_utm_builder_fe_app=self.webpackChunk_utm_builder_fe_app||[]).push([[107],{44842:function(e,n,r){r.d(n,{Z:function(){return R},x:function(){return U}});var t=r(32723),o=r(33028),i=r(34795),a=r(2867),u=r(30969),s=r(50576),c=r.n(s),l=r(72461),d=r(95400),f=r(29555),p=r(41361),h=r(29352);function v(e){if(window.parent!==window)return window.parent.postMessage(JSON.stringify({action:"copy",request:e}),"https://www.utm-builder.com"),void window.parent.postMessage(JSON.stringify({action:"copy",request:e}),"https://utm-builder.com");if(window.navigator&&window.navigator.clipboard)try{return void navigator.clipboard.writeText(e)}catch(n){}!function(e){var n,r=document.activeElement,t=document.createElement("textarea");t.style.position="absolute",t.style.left="-9999px",t.style.top="0",t.id="copytext",document.body.appendChild(t),t.textContent=e,t.focus(),t.setSelectionRange(0,t.value.length),r&&"function"===typeof r.focus&&r.focus();null===(n=t.parentNode)||void 0===n||n.removeChild(t)}(e)}var m=r(26198);function x(){return(x=(0,i.Z)((0,t.Z)().mark((function e(n){var r,o,i,a;return(0,t.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.shortener,o=n.url,i=n.slashTag,e.next=3,f.ZP.shortLinks("create",{destinationURL:o,shortener:r,slashTag:i||void 0});case 3:if(!(a=e.sent).error&&a.data){e.next=6;break}throw new Error(a.error);case 6:return e.abrupt("return",{shortener:r,shortUrl:a.data.shortURL});case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function w(e){return Promise.all(e.map((function(e){return function(e){return x.apply(this,arguments)}({url:e.outputUrl,shortener:e.shortener,slashTag:e.slashTag})})))}function g(e){return y.apply(this,arguments)}function y(){return(y=(0,i.Z)((0,t.Z)().mark((function e(n){var r;return(0,t.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(window.navigator&&window.navigator.clipboard){e.next=2;break}return e.abrupt("return",Z(n));case 2:return e.prev=2,e.next=5,w(n);case 5:return v((r=e.sent).map((function(e){return e.shortUrl})).join("\n")),e.abrupt("return",r);case 10:e.prev=10,e.t0=e.catch(2),console.log(e.t0);case 13:case"end":return e.stop()}}),e,null,[[2,10]])})))).apply(this,arguments)}function Z(e){return new Promise((function(n,r){var t=null,o=void 0,i=!1,a=[];w(e).then((function(e){o=e,t=e.map((function(e){return e.shortUrl})).join("\n")})).catch((function(e){return console.log("Shortening Error",e),a.map(clearTimeout),r(e)}));for(var u=800;u<1500;u+=200){var s=setTimeout(c,u);a.push(s)}return void setTimeout((function(){c(!0)}),1600);function c(e){if(!i&&t)return v(t),i=!0,a.map(clearTimeout),n(o);e&&r("SHORTLINK_FAILED")}}))}function b(e){return function(n){n.payload=n.payload||n.data,e(n)}}function j(e){return function(){var n=(0,i.Z)((0,t.Z)().mark((function n(r){var o,i,a,u,s,c,l,d;return(0,t.Z)().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:o=b(r),i=(0,p.Z)(e),n.prev=2,i.s();case 4:if((a=i.n()).done){n.next=28;break}if(u=a.value,s=u.shouldSave,c=u.profileId,l=u.fieldValues,o({type:"SET_FIELD_HISTORIES",data:{profileId:c,fieldValues:l}}),s){n.next=10;break}return n.abrupt("return");case 10:return n.prev=10,n.next=13,f.ZP.links("create",u);case 13:if(!(d=n.sent).error){n.next=16;break}throw d.error;case 16:o({type:"addSuccess",data:"Link Saved"}),o({type:"MERGE_PROFILE_VALUES",data:{_id:c,linkCount:d.data}}),n.next=26;break;case 20:if(n.prev=20,n.t0=n.catch(10),console.log(n.t0),"PROFILE_INACTIVE"===n.t0){n.next=25;break}return n.abrupt("return");case 25:o({type:"TOGGLE_ACTIVE_STATUS",data:{profileId:c,active:!1}});case 26:n.next=4;break;case 28:n.next=33;break;case 30:n.prev=30,n.t1=n.catch(2),i.e(n.t1);case 33:return n.prev=33,i.f(),n.finish(33);case 36:case"end":return n.stop()}}),n,null,[[2,30,33,36],[10,20]])})));return function(e){return n.apply(this,arguments)}}()}function k(e,n){return{type:"GET_URL",data:{copyState:e,id:n}}}var T=r(90065),S=r(17090),E=(r(6882),r(37574));function I(e,n){return e.get?e.get(n):e[n]}function U(e){return(0,u.useMemo)((function(){return null!==e&&void 0!==e&&e.toJS?e.toJS():e}),[I(e,"_id"),I(e,"updateId")])}var L=function(e,n){return e&&"none"!==e.type?[!1,e]:null!==n&&void 0!==n&&n.activeShortener&&"none"!==n.activeShortener?[!0,n.activeShortener]:[!0,{type:"none",domainURL:"",shortenerId:""}]};function _(e){return!!e&&/^[A-Z0-9-]+$/i.test(e)}var C=function(e){var n=(0,T.T)(),r=(0,T.C)((function(e){var n;return null===(n=e.userState)||void 0===n?void 0:n.user})),s=e.profile,p=e.profileType,x=void 0===p?"":p,w=function(){return/template/i.test(x)},y=function(e){var n=e.updateId;return[e._id,n].join("|")}(e.profile),Z=(0,u.useState)(e.url||"https://app.utm-builder.com/test-url"),S=(0,a.Z)(Z,2),I=S[0],U=S[1],C=(0,u.useState)(!1),R=(0,a.Z)(C,2),N=R[0],O=R[1],M=(0,u.useState)({value:"",valid:null}),P=(0,a.Z)(M,2),D=P[0],F=P[1],A=(0,u.useMemo)((function(){var e=c().debounce((0,i.Z)((0,t.Z)().mark((function e(){var n,i,u,c,l,d,p,h,v;return(0,t.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(_(D.value)){e.next=2;break}return e.abrupt("return");case 2:if(n=L(null===s||void 0===s?void 0:s.shortener,r),i=(0,a.Z)(n,2),u=i[0],c=i[1],l=u?c.type:c,d={shortener:l,slashTag:D.value},l&&D.value){e.next=7;break}return e.abrupt("return");case 7:return e.next=9,f.ZP.shortLinks("checkAvailable",d);case 9:p=e.sent,h=p.error,v=p.data,F((function(e){return e.value!==d.slashTag?e:(0,o.Z)((0,o.Z)({},e),{},{valid:!h&&v?"VALID":"USED"})}));case 13:case"end":return e.stop()}}),e)}))),500);return e}),[D.value,y,r]);if((0,u.useEffect)((function(){return A(),function(){A.cancel()}}),[A]),N)return(0,E.jsx)(l.l_,{push:!0,to:"/app/shortener-domains"});var H=(0,u.useMemo)((function(){var u=L(null===s||void 0===s?void 0:s.shortener,r),l=(0,a.Z)(u,2),d=(l[0],l[1]),p=w(),x=!p&&!s.active,Z={slashTag:D,url:I,shortener:p?"none":d.domainURL,blocked:x,updateId:y||1,getFieldHistory:function(e){if(!p)return n(function(e){var n=e.profileId,r=e.fieldId;return(0,m.m)("GET_FIELD_HISTORY",function(){var n=(0,i.Z)((0,t.Z)().mark((function n(r){return(0,t.Z)().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",f.ZP.links("getFieldHistory",e));case 1:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}(),{profileId:n,fieldId:r})}(e))},getURL:function(r){var u=e.profileType,s=void 0===u?"":u,c=e.profile,l=e.location,d=void 0===l?"dash":l,f=e.user,p=L(c.shortener,f),m=(0,a.Z)(p,2),x=m[0],w=m[1],y=x?w.type:w,Z=!(!/template/i.test(s)&&!c.active)&&!/template/i.test(s),T=r.map((function(e){return(0,o.Z)((0,o.Z)({},e),{},{outputUrl:e.outputUrl||"",shouldSave:Z,creationSource:"app-"+d,slashTag:e.slashTag,shortener:"none"===e.shortener?"none":y,profileId:(null===e||void 0===e?void 0:e.profileId)||c._id})}));return n(function(e){var n=(0,h.Z)();if(!e.length)throw new Error("Payload required");return function(){var r=(0,i.Z)((0,t.Z)().mark((function r(i,a){var u,s,c;return(0,t.Z)().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(u=b(i),r.prev=1,u(k("COPYING",n)),v(e.map((function(e){return e.outputUrl})).join("\n")),"none"===(void 0===(s=e[0].shortener)?"none":s)){r.next=13;break}return r.next=9,g(e);case 9:if(c=r.sent){r.next=12;break}throw new Error("Shortening Error");case 12:e=e.map((function(e,n){var r=null===c||void 0===c?void 0:c[n];return r?(0,o.Z)((0,o.Z)({},e),{},{shortUrl:r.shortUrl}):e}));case 13:u(k("DONE",n)),r.next=19;break;case 16:r.prev=16,r.t0=r.catch(1),u(k("ERROR",n));case 19:setTimeout((function(){u(k(null,n))}),600),i(j(e));case 21:case"end":return r.stop()}}),r,null,[[1,16]])})));return function(e,n){return r.apply(this,arguments)}}()}(T))},changeURL:function(e){U(e)},openShortenerConfig:function(){w()||O(!0)},profile:c().cloneDeep(s),defaults:s.config.defaults,setSlashTag:function(e){var n=!_(e);F({valid:n?"INVALID":"CHECKING",value:e}),n||A()}};return Z}),[y,D,A]);return(0,E.jsx)(d.UILogic,(0,o.Z)((0,o.Z)({toggleUTMs:!0},H),{},{url:I,children:e.children}))},R=function(e){return(0,E.jsx)(S.Z,{children:(0,E.jsx)(C,(0,o.Z)({},e))})}},17090:function(e,n,r){r.d(n,{Z:function(){return c}});var t=r(9249),o=r(87371),i=r(45754),a=r(80551),u=r(30969),s=r(37574),c=function(e){(0,i.Z)(r,e);var n=(0,a.Z)(r);function r(e){var o;return(0,t.Z)(this,r),(o=n.call(this,e)).state={hasError:!1,retriedCount:0},o}return(0,o.Z)(r,[{key:"componentDidCatch",value:function(e,n){console.log("CATCH"),console.log(e,n),window.Sentry.captureException(e)}},{key:"componentDidUpdate",value:function(e,n){}},{key:"componentWillUnmount",value:function(){clearInterval(this.timeout)}},{key:"render",value:function(){var e=this.props,n=e.fallback,r=e.children;return this.state.hasError?void 0===n?(0,s.jsx)("h1",{children:"Something went wrong."}):n:r}}],[{key:"getDerivedStateFromError",value:function(e){return{hasError:!0}}}]),r}(u.Component)},41505:function(e,n,r){r.r(n),r.d(n,{default:function(){return a}});var t=r(68424),o=r(37574);function i(){window.location.reload(!0)}function a(e){return(0,o.jsx)(t.W2,{children:(0,o.jsx)(t.iv,{children:(0,o.jsxs)("div",{className:"jumbotron text-center",children:[(0,o.jsxs)("h2",{children:["Looks like there was an update ",(0,o.jsx)(t.Fa,{i:"wrench"})]}),(0,o.jsx)("p",{children:"Our Dev's must have been busy at work since you first loaded this page, because there is a newer version of the UTM-Builder App . Try reloading the page or clicking the reload button below!"}),(0,o.jsx)(t.un,{prim:!0,lg:!0,onClick:i,children:"Reload Page"})]})})})}},55126:function(e,n,r){r.r(n),r.d(n,{default:function(){return h}});var t=r(30969),o=r(68424),i=r(95400),a=r(44842),u=r(90065),s=r(99994),c=r(37574),l={maxHeight:"85vh"},d={maxHeight:"800px",overflowX:"hidden"},f={paddingBottom:"0px"},p=t.memo((function(){return(0,c.jsxs)("div",{className:"container-fluid ui-flex-container builder",style:l,children:[(0,c.jsx)(i.UrlInput,{}),(0,c.jsx)("div",{className:"fields-mid",style:d,children:(0,c.jsx)(i.Fields,{})}),(0,c.jsx)("div",{className:"btm-fixed",style:f,children:(0,c.jsx)(i.UTMOutput,{})})]})}));function h(){var e=(0,u.T)(),n=(0,u.C)(s.tM),r=(0,u.C)((function(e){return e.userState.user}));return(0,t.useEffect)((function(){var n=function(n){var r=n.key,t=n.newValue;"windowdispatch"===r&&t&&e(JSON.parse(t))};return window.addEventListener("storage",n),function(){return window.removeEventListener("storage",n)}}),[]),(0,c.jsx)(o.W2,{children:(0,c.jsx)(o.iv,{children:n?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)("h2",{children:[(0,c.jsx)("small",{children:"Title:"})," ",n.title,(0,c.jsxs)("small",{children:[" (",n._id,")"]})]}),(0,c.jsx)("p",{className:"soft",children:"If the convention appears out of sync, try reload the editor window, or opening a fresh preview window from the editor."}),(0,c.jsx)("div",{children:(0,c.jsx)(a.Z,{location:"preview",user:r,profile:n,toggleUTMs:!0,children:(0,c.jsx)(p,{})})})]}):(0,c.jsxs)("div",{children:[(0,c.jsx)("h2",{children:"Convention Preview"}),(0,c.jsx)("p",{children:"Convention out of Sync. Try reload the editor window, or opening a fresh preview window from the editor."})]})})})}},44953:function(e,n,r){r.r(n),r.d(n,{default:function(){return c}});var t=r(2867),o=r(41361),i=r(30969),a=r(72461),u=r(68424),s=r(37574);function c(){var e=(0,a.k6)(),n=(0,i.useMemo)((function(){var n,r=new URLSearchParams(e.location.search),t=[],i=(0,o.Z)(r.entries());try{for(i.s();!(n=i.n()).done;){var a=n.value;t.push(a)}}catch(u){i.e(u)}finally{i.f()}return t}),[e]);return(0,s.jsx)(u.W2,{children:(0,s.jsx)(u.iv,{children:(0,s.jsxs)("div",{className:"jumbotron text-center",children:[(0,s.jsxs)("h2",{children:["Let's investigate these UTMs ",(0,s.jsx)(u.Fa,{i:"wrench"})]}),(0,s.jsx)("p",{className:"soft",children:(0,s.jsxs)("small",{children:["URL: ",location.href]})}),(0,s.jsx)("ul",{className:"list-group text-left",children:n.map((function(e){var n=(0,t.Z)(e,2),r=n[0],o=n[1];return(0,s.jsxs)(u.Li,{children:[r,": ",(0,s.jsx)("b",{children:o})]},r)}))})]})})})}},6882:function(){}}]); //# sourceMappingURL=Fallback.e66d1db8.chunk.js.map